/*A Module*/
/*TestA.c 文件
实现回调函数*/
#include "test.h"
#include<stdio.h>
#include<string.h>
#include <stdlib.h>
#include <pthread.h>
static pthread_t gs_VencPid;

void callback_fun(int event)
{
	switch(event)
	{
		case 1:
			{
				printf("ABCDEFG.\n");
				
			}
			break;
		case 2:
			{
				printf("abcdefg.\n");
			}
			break;
		case 3:
			{
				printf("1234567.\n");
			}
			break;
		case 4:
			{
				printf("7654321.\n");
			}
			break;
		default:
			{
				printf("New event, %d.\n",event);
			}
	}
}


// char buffer[50];
char * buffer = NULL;
// int lens;
void VideoEngineCallback(int encChannelId, int encWidth, int encHigh, void *encBuf, int size)
{
   printf("\r\n=====VideoEngineCallback get enc(%d) size (%d)=====\n",encChannelId,size);
   printf("encBuf = %s\n",(char*) encBuf);
   printf("encBuf = %p\n",(char*) encBuf);
   printf("buffer = %p\n",buffer);

	memcpy(buffer,encBuf,strlen(encBuf)+1) ;

}



void main()
{
	// int event = 0;
	// Compute_ST ptr_compute;
	
	// ptr_compute.index = 1;
	// ptr_compute.function = callback_fun;
	// //注册回调函数
	// if(-1 == Registe_Callback_Fun(&ptr_compute))
	// {
	// 	printf("Registe failed.\n");
	// }

	char * bufferCB = (char *)malloc(100);
	buffer = bufferCB;
	pthread_create(&gs_VencPid, 0, test_fun, NULL);
	
	while(1)
	// for(;;)
	{
		// printf("Enter number:");
		// scanf("%d", &event);
		
		// if(event == 0)
		// {
		// 	return;
		// }
		// //触发事件
		// mgmtb_fun(event);

		// char * bufferCB = (char *)malloc(100);
		// buffer = bufferCB;
		// usleep(10 * 1000);
		// memcpy(bufferCB,&buffer,lens + 1) ;
		CODEC_encSetCallback(VideoEngineCallback);
		usleep(10 * 1000);
   		printf("bufferCB = %s\n",bufferCB);
		// free(bufferCB);
	}

	free(bufferCB);

	return;
}
